<template>
  <el-dialog
    :close-on-click-modal="false"
    :title="title"
    :visible.sync="dialogFormVisible"
    width="1000px"
    @close="close"
    :append-to-body="true"
  >
    <el-form ref="form" :model="form" :rules="rules" label-width="120px">
      <el-row :gutter="20">
        <el-col :span="8">
          <el-form-item label="名称" prop="mingcheng">
            <el-input
              v-model.trim="form.mingcheng"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="唯一编码" prop="weiyibm">
            <el-input
              v-model.trim="form.weiyibm"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="类型" prop="leixing">
            <el-input
              v-model.trim="form.leixing"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="型别" prop="xingbie">
            <el-input
              v-model.trim="form.xingbie"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="出厂号码" prop="chuchanghm">
            <el-input
              v-model.trim="form.chuchanghm"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="单位">
            <el-input
              v-model.trim="form.danwei"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="挂载号" prop="guazaih">
            <el-input
              v-model.trim="form.guazaih"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="归属号" prop="guishuh">
            <el-input
              v-model.trim="form.guishuh"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="归属机型" prop="guishujx">
            <el-input
              v-model.trim="form.guishujx"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="规定返修周期">
            <el-input
              v-model.trim="form.guidingfxzq"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="条码">
            <el-input
              v-model.trim="form.tiaoma"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="专业">
            <el-input
              v-model.trim="form.zhuanye"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="编码">
            <el-input
              v-model.trim="form.bianma"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="重要度">
            <el-input
              v-model.trim="form.zhongyaod"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="生产厂家">
            <el-input
              v-model.trim="form.shengchancj"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="出厂日期" prop="chuchangrq">
            <el-date-picker
              v-model="form.chuchangrq"
              type="date"
              placeholder="选择日期"
              format="yyyy-MM-dd"
              value-format="yyyy-MM-dd"
            ></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="计时类型">
            <el-input
              v-model.trim="form.jishilx"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="总工作时次">
            <el-input
              v-model.trim="form.zonggongzsc"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="修后工作时次">
            <el-input
              v-model.trim="form.xiuhougzsc"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="删序号">
            <el-input
              v-model.trim="form.cexuh"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="图纸编号">
            <el-input
              v-model.trim="form.tuzhibh"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="批号">
            <el-input
              v-model.trim="form.pihao"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="现处状况">
            <el-input
              v-model.trim="form.xianchuzk"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="状况说明">
            <el-input
              v-model.trim="form.zhuangkuangsm"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="存放位置">
            <el-input
              v-model.trim="form.cunfangwz"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="翻修次数">
            <el-input
              v-model.trim="form.fanxiucs"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="处于超技术状态">
            <el-input
              v-model.trim="form.chuyucjszt"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="安装位置">
            <el-input
              v-model.trim="form.anzhuangwz"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="位置">
            <el-input
              v-model.trim="form.weizhi"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="安装序号">
            <el-input
              v-model.trim="form.anzhuangxh"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="是否启用">
            <el-input
              v-model.trim="form.shifouqy"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="工程号">
            <el-input
              v-model.trim="form.gongchengh"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="章节号">
            <el-input
              v-model.trim="form.zhangjieh"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="备注">
            <el-input
              v-model.trim="form.beizhu"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>

        <!-- 隔断 -->
        <!-- 隔断 -->
        <!-- 隔断 -->
        <!-- 隔断 -->
        <!-- 隔断 -->
        <!-- <el-col :span="8">
          <el-form-item label="挂架名称" prop="waiguamc">
            <el-input
              v-model.trim="form.waiguamc"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="货架选择" prop="huojiaxz">
            <el-select v-model="form.huojiaxz" placeholder="请选择">
              <el-option
                v-for="(item, index) in $util.gethuojiaxz()"
                :key="index"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="型别">
            <el-select v-model="form.leixing" placeholder="请选择">
              <el-option
                v-for="(item, index) in guajialx"
                :key="index"
                :label="item.leixingmc"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="出厂号码">
            <el-input
              v-model.trim="form.chuchanghm"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="现处位置">
            <el-select v-model="form.xianchuwz" placeholder="请选择">
              <el-option
                v-for="(item, index) in $util.getguajiawz()"
                :key="index"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="生产厂家">
            <el-input
              v-model.trim="form.shengchancj"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="出厂日期" prop="chuchangrq">
            <el-date-picker
              v-model="form.chuchangrq"
              type="date"
              placeholder="选择日期"
              format="yyyy-MM-dd"
              value-format="yyyy-MM-dd"
            ></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="挂弹钩出厂日期" prop="guadanccrq">
            <el-date-picker
              v-model="form.guadanccrq"
              type="date"
              placeholder="选择日期"
              format="yyyy-MM-dd"
              value-format="yyyy-MM-dd"
            ></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="检修日期" prop="jianxiurq">
            <el-date-picker
              v-model="form.jianxiurq"
              type="date"
              placeholder="选择日期"
              format="yyyy-MM-dd"
              value-format="yyyy-MM-dd"
            ></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="下次检修日期" prop="xiacijxrq">
            <el-date-picker
              v-model="form.xiacijxrq"
              type="date"
              placeholder="选择日期"
              format="yyyy-MM-dd"
              value-format="yyyy-MM-dd"
            ></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="唯一编码">
            <el-input
              v-model.trim="form.weiyibm"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="使用次数">
            <el-input
              v-model.trim="form.shiyongcs"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="剩余次数">
            <el-input
              v-model.trim="form.shengyucs"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="归属飞机号">
            <el-input
              v-model.trim="form.guishufjh"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="挂载飞机号">
            <el-input
              v-model.trim="form.guazaifjh"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="规定返修周期">
            <el-input
              v-model.trim="form.guidingfxzq"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="预测返修周期">
            <el-input
              v-model.trim="form.yucefxzq"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="返修厂家">
            <el-input
              v-model.trim="form.fanxiucj"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="修后修理周期">
            <el-input
              v-model.trim="form.xiuhouxlzq"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="历史故障情况">
            <el-input
              v-model.trim="form.lishigzqk"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="技术通报落实情况">
            <el-input
              v-model.trim="form.jishutblsqk"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="检修人">
            <el-input
              v-model.trim="form.jianxiur"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="备注">
            <el-input
              v-model.trim="form.beizhu"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="入库人">
            <el-input
              v-model.trim="form.rukur"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="经手人">
            <el-input
              v-model.trim="form.jingshour"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="出库人">
            <el-input
              v-model.trim="form.chukur"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="挂弹钩号码">
            <el-input
              v-model.trim="form.guadanghm"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="挂弹钩使用次数">
            <el-input
              v-model.trim="form.guadangshiycs"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="挂弹钩剩余次数">
            <el-input
              v-model.trim="form.guadangshengycs"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="挂弹钩预警">
            <el-input
              v-model.trim="form.guadangyj"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="火箭发射器">
            <el-input
              v-model.trim="form.huojianfsq"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="管的数量">
            <el-input
              v-model.trim="form.guansl"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="管的寿命">
            <el-input
              v-model.trim="form.guansm"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="已发射次数">
            <el-input
              v-model.trim="form.yifascs"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="剩余次数">
            <el-input
              v-model.trim="form.shengyucishu"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="到2次预警">
            <el-input
              v-model.trim="form.yujing"
              autocomplete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-col> -->
        <!-- <el-col :span="8">
          <el-form-item label="托盘">
            <el-select
              v-model="form.tuopanid"
              clearable
              filterable
              placeholder="请选择"
            >
              <el-option
                v-for="(item, index) in tuopanlist"
                :key="index"
                :label="item.tuopanbh"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="货位">
            <el-select
              v-model="form.huoweiid"
              clearable
              filterable
              placeholder="请选择"
            >
              <el-option
                v-for="(item, index) in huoweilist"
                :key="index"
                :label="item.huoweibh"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="挂架状态">
            <el-select v-model="form.guajiazt" placeholder="请选择">
              <el-option
                v-for="(item, index) in $util.getguajiazt()"
                :key="index"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="操作状态">
            <el-select v-model="form.caozuozt" placeholder="请选择">
              <el-option
                v-for="(item, index) in $util.getguajiaczzt()"
                :key="index"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col> -->
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="close">取 消</el-button>
      <el-button type="primary" @click="save">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
  import { addguajia, updateguajia } from '@/api/kunei'
  import {
    queryguajialxAll,
    queryHuoWeiList,
    queryTuoPanListAll,
  } from '@/api/cangkujichu'
  export default {
    name: 'WarehouseManagement',
    data() {
      return {
        form: {
          waiguamc: '',
          leixing: '',
          chuchanghm: '',
          xianchuwz: '',
          shengchancj: '',
          chuchangrq: '',
          weiyibm: '',
          shiyongcs: '',
          shengyucs: '',
          guishufjh: '',
          guazaifjh: '',
          guidingfxzq: '',
          yucefxzq: '',
          fanxiucj: '',
          xiuhouxlzq: '',
          lishigzqk: '',
          jishutblsqk: '',
          jianxiurq: '',
          xiacijxrq: '',
          jianxiur: '',
          beizhu: '',
          rukur: '',
          jingshour: '',
          chukur: '',
          guadanghm: '',
          guadanccrq: '',
          guadangshiycs: '',
          guadangshengycs: '',
          guadangyj: '',
          huojianfsq: '',
          guansl: '',
          guansm: '',
          yifascs: '',
          shengyucishu: '',
          yujing: '',
          tuopanid: '',
          huoweiid: '',
          guajiazt: '',
          huojiaxz: '',
        },
        rules: {
          mingcheng: [{ required: true, message: '请输入', trigger: 'blur' }],
          weiyibm: [{ required: true, message: '请输入', trigger: 'blur' }],
          leixing: [{ required: true, message: '请输入', trigger: 'blur' }],
          xingbie: [{ required: true, message: '请选择', trigger: 'blur' }],
          chuchanghm: [{ required: true, message: '请选择', trigger: 'blur' }],
          jianxiurq: [{ required: true, message: '请选择', trigger: 'blur' }],
          xiacijxrq: [{ required: true, message: '请选择', trigger: 'blur' }],
        },
        title: '',
        dialogFormVisible: false,
        guajialx: [],
        huoweilist: [],
        tuopanlist: [],
      }
    },
    created() {
      this.getguajialx()
    },
    methods: {
      async getguajialx() {
        let res = await queryguajialxAll()
        this.guajialx = res.data
        const res2 = await queryHuoWeiList()
        const res3 = await queryTuoPanListAll()
        this.huoweilist = res2.data
        this.tuopanlist = res3.data
      },
      showEdit(row) {
        if (!row) {
          this.title = '新增'
        } else {
          this.title = '编辑'

          this.form = Object.assign({}, row)
        }
        this.dialogFormVisible = true
      },
      close() {
        this.$refs['form'].resetFields()
        this.form = this.$options.data().form
        this.dialogFormVisible = false
      },
      save() {
        this.$refs['form'].validate(async (valid) => {
          if (valid) {
            let res = null
            if (this.title == '新增') {
              console.log(this.form)
              res = await addguajia(this.form)
            } else {
              res = await updateguajia(this.form)
            }
            this.$baseMessage(res.msg, 'success')
            this.$emit('fetch-data')
            this.close()
          } else {
            return false
          }
        })
      },
    },
  }
</script>
<style lang="scss" scoped>
  .el-select--small,
  .el-date-editor.el-input,
  .el-date-editor.el-input__inner {
    width: 100%;
  }
</style>
